﻿using System;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Renren.Services;

namespace Renren.Pages
{
    public partial class LoginPage : PhoneApplicationPage
    {
        public LoginPage()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler((sender, args) =>
            {
                this.LoginBrowser.Navigate(new Uri(RenrenSettings.LoginRequestUri, UriKind.Absolute));
            });

            this.LoginBrowser.Navigated += new EventHandler<NavigationEventArgs>((sender, args) =>
            {
                if (RenrenSettings.ParseLoginReturnedUri(args.Uri))
                {
                    App.LoginUser = null;
                    this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }
            });
        }
    }
}